class BookDetailController < ApplicationController
  def show
    @bookid = params[:id]
    @categories = Category.all
    @book = Book.find(@bookid)
    @book. numviewed = @book. numviewed+1
    @book.save
    @category = Category.find(@book.category_id)
    
     @other_books = Book.find(:all,
      :conditions => ["id != ? AND category_id = ?",@bookid,@category.id],
      :limit => 4,
      :order => 'created_at asc'
    ) 
    respond_to do |format|
      format.html # show.html.erb
      format.json { render json: @book }
    end
  end
end
